#include<iostream>
using namespace std;

int main(){
    int n,a[100];
  //  cout<<"请输入"<<endl;
    cin>>n;
    int i;
    int judge;
    for ( i = 0; i < n; i++)
    {
        cin>>a[i];
        /* code */
    }
    int p,q,m,o;
    for ( i = 0; i < n; i++)
    {
        /* code */
        p=a[i]/1000;
        q=(a[i]/100)%10;
        m=(a[i]%100)/10;
        o=a[i]%10;
        if (p==o&&q==m)
        {
            /* code */judge=1;
        }
        else{
            judge=0;
        }
        cout<<judge<<endl;
        
    }
    return 0;
    
    



}

